#! /bin/sh /usr/share/dpatch/dpatch-run
## 05_pedantic.dpatch by Daniel Kahn Gillmor <dkg@fifthhorseman.net>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: changes to make clean up compilation

@DPATCH@
diff -urNad redir-2.2.1~/Makefile redir-2.2.1/Makefile
--- redir-2.2.1~/Makefile	2005-10-22 23:11:41.000000000 -0400
+++ redir-2.2.1/Makefile	2005-10-22 23:11:48.818368360 -0400
@@ -32,7 +32,7 @@
 # if your system lacks getopt_long, remove the comment from this line
 OBJS = redir.o $(GETOPT_OBJS)
 
-CFLAGS = -O2 -Wall $(STR_CFLAGS) $(WRAP_CFLAGS) $(EXTRA_CFLAGS)
+CFLAGS = -O2 -Wall --pedantic $(STR_CFLAGS) $(WRAP_CFLAGS) $(EXTRA_CFLAGS)
 LDFLAGS = -s
 
 # solaris, and others, may also need these libraries to link
diff -urNad redir-2.2.1~/redir.c redir-2.2.1/redir.c
--- redir-2.2.1~/redir.c	2005-10-22 23:11:48.282449832 -0400
+++ redir-2.2.1/redir.c	2005-10-22 23:12:23.201141384 -0400
@@ -73,6 +73,7 @@
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <sys/time.h>
+#include <time.h>
 #include <sys/wait.h>
 #include <netinet/in.h>
 #include <arpa/inet.h>
@@ -460,7 +461,7 @@
 	int lport, rport;
 	int remip[4];
 	int localsock;
-	int socksize = sizeof(struct sockaddr_in);
+	size_t socksize = sizeof(struct sockaddr_in);
 
 	struct sockaddr_in newsession;
 	struct sockaddr_in sockname;
@@ -509,7 +510,7 @@
 	if(getsockname(localsock, (struct sockaddr *)&sockname, &socksize) < 0) {
 		perror("getsockname");
 		if (dosyslog)
-			syslog(LOG_ERR, "getsockname failed: %m");
+			syslog(LOG_ERR, "getsockname failed: %s",strerror(errno));
 		exit(1);
 	}
 
@@ -562,7 +563,7 @@
 	switch(fork())
 	{
      	case -1: /* Error */
-     		syslog(LOG_ERR, "Couldn't fork: %m");
+     		syslog(LOG_ERR, "Couldn't fork: %s",strerror(errno));
      		_exit(1);
      	case 0:  /* Child */
 	{
@@ -723,7 +724,7 @@
 	int clisock;
 	int targetsock;
 	struct sockaddr_in client;
-	int clientlen = sizeof(client);
+	size_t clientlen = sizeof(client);
 	int accept_errno;
      
 	debug("top of accept loop\n");
@@ -734,7 +735,7 @@
 		perror("server: accept");
 
 		if (dosyslog)
-			syslog(LOG_ERR, "accept failed: %m");
+			syslog(LOG_ERR, "accept failed: %s",strerror(errno));
 
 		/* determine if this error is fatal */
 		switch(accept_errno) {
@@ -768,7 +769,7 @@
      		perror("(server) fork");
 
      		if (dosyslog)
-     			syslog(LOG_ERR, "(server) fork failed: %m");
+     			syslog(LOG_ERR, "(server) fork failed: %s",strerror(errno));
 
      		_exit(1);
      	case 0:  /* Child */
@@ -795,7 +796,7 @@
      		perror("(child) fork");
 
      		if (dosyslog)
-     			syslog(LOG_ERR, "(child) fork failed: %m");
+     			syslog(LOG_ERR, "(child) fork failed: %s",strerror(errno));
 
      		_exit(1);
      	case 0:  /* Child */
@@ -826,7 +827,7 @@
 		perror("target: socket");
 	  
 		if (dosyslog)
-			syslog(LOG_ERR, "socket failed: %m");
+			syslog(LOG_ERR, "socket failed: %s",strerror(errno));
 		
 		_exit(1);
 	}
@@ -850,7 +851,7 @@
    only be different if the input value is 0 (let the system pick a 
    port) */
 			if (dosyslog)
-				syslog(LOG_ERR, "bind failed: %m");
+				syslog(LOG_ERR, "bind failed: %s",strerror(errno));
 
 			_exit(1);
 		}
@@ -862,7 +863,7 @@
 		perror("target: connect");
 
 		if (dosyslog)
-			syslog(LOG_ERR, "bind failed: %m");
+			syslog(LOG_ERR, "bind failed: %s",strerror(errno));
 
 		_exit(1);
 	}
@@ -923,7 +924,7 @@
 			perror("server: socket");
 
 			if (dosyslog)
-				syslog(LOG_ERR, "socket failed: %m");
+				syslog(LOG_ERR, "socket failed: %s",strerror(errno));
 
 			exit(1);
 		}
@@ -962,7 +963,7 @@
 			perror("server: bind");
 
 			if (dosyslog)
-				syslog(LOG_ERR, "bind failed: %m");
+				syslog(LOG_ERR, "bind failed: %s",strerror(errno));
 
 			exit(1);
 		}
@@ -980,7 +981,7 @@
 			perror("server: listen");
 
 			if (dosyslog)
-				syslog(LOG_ERR, "listen failed: %m");
+				syslog(LOG_ERR, "listen failed: %s",strerror(errno));
 
 			exit(1);
 		}
@@ -1059,7 +1060,7 @@
 	if (inetd) {
 		int targetsock;
 		struct sockaddr_in client;
-		int client_size = sizeof(client);
+		size_t client_size = sizeof(client);
 
 #ifdef USE_TCP_WRAPPERS
 		request_init(&request, RQ_DAEMON, ident, RQ_FILE, 0, 0);
@@ -1079,7 +1080,7 @@
 			perror("target: socket");
 
 			if (dosyslog)
-				syslog(LOG_ERR, "targetsock failed: %m");
+				syslog(LOG_ERR, "targetsock failed: %s",strerror(errno));
 
 			exit(1);
 		}
@@ -1097,7 +1098,7 @@
 				perror("bind_addr: cannot bind to forcerd outgoing addr");
 				 
 				if (dosyslog)
-					syslog(LOG_ERR, "bind failed: %m");
+					syslog(LOG_ERR, "bind failed: %s",strerror(errno));
 				 
 				exit(1);
 			}
@@ -1109,7 +1110,7 @@
 			perror("target: connect");
 
 			if (dosyslog)
-				syslog(LOG_ERR, "connect failed: %m");
+				syslog(LOG_ERR, "connect failed: %s",strerror(errno));
 
 			exit(1);
 		}
